# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=frisbeelite
pkgver=1.2
pkgrel=9
groups=('blackarch' 'blackarch-fuzzer')
pkgdesc='A GUI-based USB device fuzzer.'
arch=('any')
url='https://github.com/nccgroup/FrisbeeLite'
license=('GPL3')
depends=('python2' 'libusb' 'python2-pyusb' 'wxwidgets-gtk3' 'python2-wxpython3')
makedepends=('git')
source=("$pkgname::git+https://github.com/nccgroup/FrisbeeLite.git")
sha512sums=('SKIP')

prepare() {
  cd $pkgname

  mv "FrisbeeLite_v$pkgver.py" "$pkgname.py"

  sed -i '/#!\/usr\/bin\/python/d' "$pkgname.py"
  sed -i '1i\#!/usr/bin/python2' "$pkgname.py"
  sed -i 's/.$//g' "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a "$pkgname.py" images dependencies "$pkgdir/usr/share/$pkgname"

  install -Dm 644 Fuzzing_USB_devices_with_FrisbeeLite.pdf \
    "$pkgdir/usr/share/doc/$pkgname/Fuzzing_USB_devices_with_FrisbeeLite.pdf"
  install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

